import 'package:flutter/material.dart';
import '../services/ScreenAdapter.dart';

class MyButton extends StatelessWidget{
  final String text;
  final Color color;
  var cb;  // 此回调函数无参数
  final double height;
  final double leftMargin;
  final double rightMargin;
  final double leftPadding;
  final double rightPadding;
  final Color textColor;
  final double borderRadius;
  final double fontSize;
  MyButton({this.text='按钮',this.color=Colors.blue,this.cb,
    this.height=70,this.leftMargin = 10, this.rightMargin = 10,
    this.textColor=Colors.white, this.borderRadius = 10,this.fontSize=12,
    this.leftPadding = 0,this.rightPadding = 0});

  @override
  Widget build(BuildContext context) {
    return InkWell(
      child: Container(
        alignment: Alignment.center,
        height: ScreenAdapter.height(this.height),
        decoration: BoxDecoration(
          color: this.color,
          borderRadius: BorderRadius.circular(this.borderRadius),
        ),
        padding: EdgeInsets.only(left: this.leftPadding,right: this.rightPadding),
        margin: EdgeInsets.only(left:this.leftMargin,right:this.rightMargin),
        child: Text(this.text,style:TextStyle(fontSize: this.fontSize, color: this.textColor)),
      ),
      onTap: cb,
    );
  }

}